<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<!--准备好一个容器-->
<div id="test">

</div>
<!--核心库引入顺序，必须先是核心库然后在引入dom库-->
<script src="../js/react.development.js" crossorigin></script>
<!--用于支持react操作dom-->
<script src="../js/react-dom.development.js"></script>
<!--引入babel，用于将jsx转为js-->
<script src="../js/babel.min.js"></script>
<script type="text/babel">
    class Time extends React.Component {

        state = {
            date: new Date(),
            number: 10
        }

        componentDidMount() {
            setInterval(() => {
                let {number} = this.state;
                this.setState({
                    date: new Date()
                })
            }, 1000)
        }

        render() {
            return (
                <div>
                    <h1>hello</h1>
                    <input type="text"/><br/>
                    <span>现在是:{this.state.date.toTimeString()}</span>
                    <span>几何级数:{this.state.number}</span>
                </div>
            )
        }
    }

    ReactDOM.render(<Time/>, document.getElementById('test'))
</script>
</body>
</html>